#include <vector>
#include <string>
using namespace std;
/*
 * @lc app=leetcode.cn id=14 lang=cpp
 *
 * [14] 最长公共前缀
 */

// @lc code=start
class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        int cur = 0;
        while (cur < strs[0].size()) {
            bool flag = false;
            for (int i = 1; i < strs.size(); i++) {
                if (cur >= strs[i].size() || strs[i][cur] != strs[0][cur]) {
                    flag = true; break;
                }
            }
            if (flag) break;
            cur++;
        }
        return strs[0].substr(0, cur);
    }
};
// @lc code=end

